﻿Public Class BarCodeEngine

#Region " D e k l a r a t i o n e n "
    Private WithEvents ScanTimer As New Timer
    Private ScanErgebnis As String
    Private ScanImGange As Boolean = False
    Public Event EingehenderScan(ScanErgebnis As String)
#End Region

#Region " K o n s t r u k t o r "
    Public Sub New()
        ScanTimer.Interval = 200
    End Sub
#End Region

#Region " Public Sub: EingehendesKeyDown () "
    Public Sub EingehendesKeyDown(Key As Char)
        If ScanImGange Then
            ScanErgebnis &= Key
            ScanTimer.Stop()
            ScanTimer.Start()
        Else
            ScanImGange = True
            ScanErgebnis = Key
            ScanTimer.Start()
        End If
    End Sub
#End Region

#Region " Private Sub: ScanTimer_Tick () "
    Public Sub ScanTimer_Tick(sender As Object, e As EventArgs) Handles ScanTimer.Tick
        ScanTimer.Stop()
        ScanImGange = False
        If CheckEAN.BerechneEanChecksum(ScanErgebnis) Then
            RaiseEvent EingehenderScan(ScanErgebnis)
        End If

        RaiseEvent EingehenderScan(ScanErgebnis)

    End Sub
#End Region

End Class
